package com.example.demo.test.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.demo.test.entity.Stat;
import com.example.demo.test.service.IStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator
 * @since 2021-05-28
 */
@RestController
@RequestMapping("/stat")
public class StatController {

    @Autowired
    private IStatService statService;

    @PostMapping("/add")
    public boolean addStat(@RequestBody Stat stat) {
        return statService.save(stat);
    }

    @GetMapping("/del/{id}")
    public boolean delStatById(@PathVariable String id) {
        return statService.removeById(id);
    }

    @PostMapping("/update")
    public boolean updateStat(@RequestBody Stat stat) {
        return statService.updateById(stat);
    }

    @PostMapping("/list")
    public List<Stat> getStatList() {
        LambdaQueryWrapper<Stat> query = Wrappers.lambdaQuery(Stat.class);
        return statService.list(query);
    }

}

